/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package persistencia.entidade;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

/**
 *
 * @author Novo usuário
 */
@Entity
@Table(name = "registro", schema = "")
public class Registro implements Serializable{

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "REGISTRO_ID", nullable = false)
    private Integer registroId;
    @Basic(optional = false)
    @Column(name = "NOME", nullable = false, length = 250)
    private String nome;
    @Column(name = "RESUMO_MOB", length = 50)
    private String resumoMob;
    @Column(name = "RESUMO_WEB", length = 250)
    private String resumoWeb;
    @Column(name = "TEXTO_MOB", length = 256)
    private String textoMob;
    @Column(name = "TEXTO_WEB", length = 1024)
    private String textoWeb;
    @Column(name = "TELEFONE", length = 8)
    private String telefone;
    @Column(name = "TELEFONE2", length = 8)
    private String telefone2;
    @Column(name = "ENDERECO", length = 250)
    private String endereco;
    @Column(name = "NUMERO", length = 10)
    private Integer numero;
    @Column(name = "BAIRRO", length = 250)
    private String bairro;
    @Column(name = "EMAIL", length = 250)
    private String email;
    @Column(name = "SITE", length = 250)
    private String site;
    @Column(name = "PESO")
    private Integer peso;
    @Column(name = "CIDADE", length = 100)
    private String cidade;
    @Column(name = "DDD", length = 3)
    private String ddd;
    @Column(name = "UF", length = 3)
    private String uf;
    @ManyToMany(mappedBy = "registroCollection", fetch = FetchType.EAGER)
    private List<Categoria> categoriaCollection;
    @Lob
    @Column(name = "img_mob", columnDefinition="longblob")
    private byte[] imgMob;
    @Lob
    @Column(name = "icone_mob", columnDefinition="longblob")
    private byte[] iconeMob;
    @Lob
    @Column(name = "icone_web", columnDefinition="longblob")
    private byte[] iconeWeb;
    @Lob
    @Column(name = "img_web", columnDefinition="longblob")
    private byte[] imgWeb;

    public Registro() {
    }

    public Registro(Integer registroId) {
        this.registroId = registroId;
    }

    public Registro(Integer registroId, String nome) {
        this.registroId = registroId;
        this.nome = nome;
    }

    public Integer getRegistroId() {
        return registroId;
    }

    public void setRegistroId(Integer registroId) {
        this.registroId = registroId;
    }

    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }

    public String getTelefone() {
        return telefone;
    }

    public void setTelefone(String telefone) {
        this.telefone = telefone;
    }

    public String getTelefone2() {
        return telefone2;
    }

    public void setTelefone2(String telefone2) {
        this.telefone2 = telefone2;
    }

    public String getEndereco() {
        return endereco;
    }

    public void setEndereco(String endereco) {
        this.endereco = endereco;
    }

    public String getBairro() {
        return bairro;
    }

    public void setBairro(String bairro) {
        this.bairro = bairro;
    }

    public String getResumoMob() {
        return resumoMob;
    }

    public void setResumoMob(String resumo) {
        this.resumoMob = resumo;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getSite() {
        return site;
    }

    public void setSite(String site) {
        this.site = site;
    }

    public Integer getPeso() {
        return peso;
    }

    public void setPeso(Integer peso) {
        this.peso = peso;
    }
    
    public String getCidade() {
        return cidade;
    }

    public void setCidade(String cidade) {
        this.cidade = cidade;
    }

    public String getDdd() {
        return ddd;
    }

    public void setDdd(String ddd) {
        this.ddd = ddd;
    }

    public List<Categoria> getCategoriaCollection() {
        if(categoriaCollection == null){
            categoriaCollection = new ArrayList<Categoria>();
        }
        return categoriaCollection;
    }

    public void setCategoriaCollection(List<Categoria> categoriaCollection) {
        this.categoriaCollection = categoriaCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (registroId != null ? registroId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Registro)) {
            return false;
        }
        Registro other = (Registro) object;
        if ((this.registroId == null && other.registroId != null) || (this.registroId != null && !this.registroId.equals(other.registroId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {

        StringBuffer sb = new StringBuffer();

        sb.append(getRegistroId());//0
        sb.append("|");
        sb.append(getNome());//1
        sb.append("|");
        sb.append(getCidade());//2
        sb.append("|");
        sb.append(getDdd());//3
        sb.append("|");
        sb.append(getBairro());//4
        sb.append("|");
        sb.append(getEmail());//5
        sb.append("|");
        sb.append(getEndereco());//6
        sb.append("|");
        sb.append(getPeso());//7
        sb.append("|");
        sb.append(getSite());//8
        sb.append("|");
        sb.append(getTelefone());//9
        sb.append("|");
        sb.append(getTelefone2());//10
        sb.append("|");
        sb.append(getUf());//11
        sb.append("|");
        sb.append(getTextoMob());//12
        sb.append("|");
        sb.append(getResumoMob());//13
        sb.append("|");
        sb.append(getNumero());//14
        sb.append("|");
        List<Categoria> cats = getCategoriaCollection();
        sb.append(cats.size());//15
        sb.append("|");
        if (cats != null) {
            for (Iterator<Categoria> it = cats.iterator(); it.hasNext();) {
                sb.append(it.next().getCategoriaId());
                sb.append("|");
            }
            sb.delete(sb.length() - 1, sb.length());
            sb.append("\n");
        }
        return sb.toString();
    }

    /**
     * @return the uf
     */
    public String getUf() {
        return uf;
    }

    /**
     * @param uf the uf to set
     */
    public void setUf(String uf) {
        this.uf = uf;
    }

    /**
     * @return the resumoWeb
     */
    public String getResumoWeb() {
        return resumoWeb;
    }

    /**
     * @param resumoWeb the resumoWeb to set
     */
    public void setResumoWeb(String resumoWeb) {
        this.resumoWeb = resumoWeb;
    }

    /**
     * @return the textoMob
     */
    public String getTextoMob() {
        return textoMob;
    }

    /**
     * @param textoMob the textoMob to set
     */
    public void setTextoMob(String textoMob) {
        this.textoMob = textoMob;
    }

    /**
     * @return the textoWeb
     */
    public String getTextoWeb() {
        return textoWeb;
    }

    /**
     * @param textoWeb the textoWeb to set
     */
    public void setTextoWeb(String textoWeb) {
        this.textoWeb = textoWeb;
    }

    /**
     * @return the imgMob
     */
    public byte[] getImgMob() {
        return imgMob;
    }

    /**
     * @param imgMob the imgMob to set
     */
    public void setImgMob(byte[] imgMob) {
        this.imgMob = imgMob;
    }

    /**
     * @return the iconeMob
     */
    public byte[] getIconeMob() {
        return iconeMob;
    }

    /**
     * @param iconeMob the iconeMob to set
     */
    public void setIconeMob(byte[] iconeMob) {
        this.iconeMob = iconeMob;
    }

    /**
     * @return the imgWeb
     */
    public byte[] getImgWeb() {
        return imgWeb;
    }

    /**
     * @param imgWeb the imgWeb to set
     */
    public void setImgWeb(byte[] imgWeb) {
        this.imgWeb = imgWeb;
    }

    /**
     * @return the iconeWeb
     */
    public byte[] getIconeWeb() {
        return iconeWeb;
    }

    /**
     * @param iconeWeb the iconeWeb to set
     */
    public void setIconeWeb(byte[] iconeWeb) {
        this.iconeWeb = iconeWeb;
    }

    /**
     * @return the numero
     */
    public Integer getNumero() {
        return numero;
    }

    /**
     * @param numero the numero to set
     */
    public void setNumero(Integer numero) {
        this.numero = numero;
    }
}
